<template>
	<view class="furniRecom">
		<navBar isBack backColor="#333" color="#333" title="家居推荐" background="#fff"></navBar>
		<view class="furniList">
			<view class="furniItem" v-for="(item,index) in furniList" :key="index" @click="GoGoodsDetaile(item,index)">
				<image :src="item.main_imgurl.path" mode=""></image>
				<p class="omit-1">{{item.product_title}}</p>
				<view class="price">
					¥{{item.price}}
					<view class="cart">
						<u-icon name="shopping-cart"></u-icon>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import service_oneN from '@/service/oneN.js'
	export default{
		data(){
			return{
				baseImg:'http://manager.ryz1620.com',
				furniList:[],
				page:1,
				pagesize:10,
				estate_id:''
			}
		},
		onReachBottom() {
			this.page++;
			uni.showLoading({
				title:'加载中'
			})
			let params = {
				page:this.page,
				pagesize:this.pagesize,
				estate_id:this.estate_id
			}
			service_oneN.getFurniList(params).then(res=>{
				console.log(res)
				if(res.code==1){
					if(!res.data.length){
						uni.showToast({
							title:'没有更多了~',
							icon:'none'
						})
						return
					}
					this.furniList = this.furniList.concat(res.data)
				}
			})
			setTimeout(function(){
				uni.hideLoading()
			},500)
		},
		onLoad(options) {
			this.$utils.getUrl()
			var id = options.estate_id
			this.estate_id = id
			console.log(id);
			this.getFurniList(id)
		},
		methods:{
			// 获取家居列表
			getFurniList(id){
				this.page = 1
				let params = {
					page:this.page,
					pagesize:this.pagesize,
					estate_id:id
				}
				service_oneN.getFurniList({
					page:this.page,
					pagesize:this.pagesize,
					estate_id:id
				}).then(res=>{
					console.log(res,'家居列表')
					if(res.code==1){
						this.furniList = res.data?res.data:[]
					}
				})
			},
			GoGoodsDetaile(item,index){
				console.log(item);
				uni.navigateTo({
					url: '/pages_mall/pages/mall/goods_details/goods_details?id=' + item.id
				})
				// `/pages_mall/pages/mall/goods_details/goods_details?id=${items.product_id}`
			},
		}
	}
</script>

<style lang="scss">
	page{height: 100%;}
	.furniRecom{
		width: 100%;
		height: 100%;
		background-color: #fff;
		.furniList{
			padding: 40rpx 32rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.furniItem{
				margin-bottom: 22rpx;
				width: 332rpx;
				height: 461rpx;
				padding: 24rpx;
				box-shadow: 0px 0px 16rpx rgba(0, 0, 0, 0.06);
				display: flex;
				flex-direction: column;
				image{width: 284rpx;height: 284rpx;border-radius: 8rpx;}
				p{margin: 20rpx 0 24rpx 0; font: 500 24rpx/44rpx PingFang SC; color:#333;}
				.price{
					display: flex;
					justify-content: space-between;
					align-items: center;
					font: 600 32rpx/52rpx PingFang SC;
					color: #C3AB7C;
					.cart{
						width: 52rpx;
						height: 52rpx;
						border-radius: 50%;
						text-align: center;
						background-color: #F9F6F3;
						
					}
				}
			}
		}
	}
</style>
